import request from '@/utils/request'
//获取简单员工列表
export const getEmployeeSimple =() => request({
  url:'/sys/user/simple',
})

export function getEmployeeList({ page,size }:EmployeeListType) {
  return request({
    url: '/sys/user',
    method: 'GET',
    params: { page, size },
  })
}

/**
 * @description: 删除员工
 * @param {*} id 员工id
 * @return {*}
 */
export function delEmployee(id:string) {
  return request({
    method: 'delete',
    url: `/sys/user/${ id }`,
  })
}
/**
 * @description: 添加员工
 * @param {*} data
 * @return {*}
 */
export function addEmployee(data:EmployeeList) {
  return request({
    method: 'post',
    url: '/sys/user',
    data,
  })
}
/**
 * @description: 导入excel
 * @param {*} data
 * @return {*}
 */
export function importEmployee(data :ExcelData[]) {
  return request({
    url: '/sys/user/batch',
    method: 'post',
    data,
  })
}

/**
 * @description: 保存员工信息
 * @param {*} data
 * @return {*}
 */

export function saveUserDetailById(data:UserInfo) {
  return request({
    url: `/sys/user/${ data.id }`,
    method: 'put', // 全量修改
    data,
  })
}
/**
 * @description: 为用户分配角色
 * @param {*} data { id:当前用户id, roleIds:选中的角色id组成的数组 }
 * @return {*}
 */
type AssignRoles= {
  id:string
  roleIds:string[]
}
export function assignRoles(data :AssignRoles) {
  return request({
    url: '/sys/user/assignRoles',
    data,
    method: 'put',
  })
}